{% extends 'base.html' %}

{% block title %}登录 - 机械臂实验系统{% endblock %}

{% block extra_css %}
<style>
    .login-container {
        max-width: 450px;
        margin: 50px auto;
        padding: 30px;
        border-radius: 10px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
        background-color: #fff;
    }
    
    .login-title {
        text-align: center;
        margin-bottom: 30px;
        color: #333;
    }
    
    .form-control {
        border-radius: 5px;
        padding: 12px;
        margin-bottom: 20px;
    }
    
    .login-btn {
        width: 100%;
        padding: 12px;
        border-radius: 5px;
        margin-top: 10px;
        background-color: #007bff;
        border: none;
    }
    
    .login-options {
        display: flex;
        justify-content: space-between;
        margin-top: 20px;
    }
    
    .robot-icon {
        text-align: center;
        margin-bottom: 20px;
        font-size: 60px;
        color: #007bff;
    }
</style>
{% endblock %}

{% block content %}
<div class="login-container">
    <div class="robot-icon">
        <i class="bi bi-robot"></i>
    </div>
    <h2 class="login-title">用户登录</h2>
    
    <form method="post" action="{% url 'login' %}">
        {% csrf_token %}
        
        <div class="mb-3">
            {{ form.username }}
            {% if form.username.errors %}
                <div class="invalid-feedback d-block">
                    {{ form.username.errors }}
                </div>
            {% endif %}
        </div>
        
        <div class="mb-3">
            {{ form.password }}
            {% if form.password.errors %}
                <div class="invalid-feedback d-block">
                    {{ form.password.errors }}
                </div>
            {% endif %}
        </div>
        
        {% if form.non_field_errors %}
            <div class="alert alert-danger">
                {% for error in form.non_field_errors %}
                    {{ error }}
                {% endfor %}
            </div>
        {% endif %}
        
        <button type="submit" class="btn btn-primary login-btn">登录</button>
    </form>
    
    <div class="login-options">
        <div>
            <a href="{% url 'register_student' %}" class="text-decoration-none">学生注册</a>
        </div>
        <div>
            <a href="{% url 'register_teacher' %}" class="text-decoration-none">教师注册</a>
        </div>
    </div>
</div>
{% endblock %} 